Skip to content

Conversation

@jeesonjohnson
Copy link

Allows you to define the name of the inner folder of the zip generated. A relevant issue can be found HERE.

Comment on lines +120 to +141
//Had to do the below, since otherwise the file did not zip in enough time.
function customZippingFunction(options, customFilePath) {
return new Promise((resolve, reject) => {
zipDir(
customFilePath || sampleZipPath,
options,
async function (err, buffer) {
if (err) {
reject(err);
return;
}
await fs
.createReadStream(xpiPath)
.pipe(unzip.Extract({ path: outputPath }))
.on("entry", (entry) => entry.autodrain())
.promise()
.then(() => resolve())
.catch(e=>reject(e));
}
);
});
}
Copy link
Author

@jeesonjohnson jeesonjohnson Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to wrap the zipping command into its own promise since it was being flaky when running tests, since the zipping often took way too long, and zipDir cannot directly be awaited.

Comment on lines +106 to +118
function customCompareMethod(file, customFilePath = "", combineCustomFilePathOrReplace = true) {
const zipBuffer = fs.readFileSync(path.join(sampleZipPath, file));
const combinedFilePath = path.join(customFilePath, file);
// Compare the different file buffers.
const fileBuffer = fs.readFileSync(
path.join(
outputPath,
combineCustomFilePathOrReplace ? combinedFilePath : customFilePath
)
);

expect(bufferEqual(zipBuffer, fileBuffer)).to.be.ok;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move the this function to the global def, but thought i would ask before changing the other aspects. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant